package io.renren.modules.news.controller;


import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.news.entity.V9NewsEntity;
import io.renren.modules.news.service.V9NewsService;

/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-10-15 14:26:23
 */
@RestController
@RequestMapping("news/v9news")
public class V9NewsController {
    @Autowired
    private V9NewsService v9NewsService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("news:v9news:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = v9NewsService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("news:v9news:info")
    public R info(@PathVariable("id") Integer id){
		V9NewsEntity v9News = v9NewsService.getById(id);

        return R.ok().put("v9News", v9News);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("news:v9news:save")
    public R save(@RequestBody V9NewsEntity v9News){
		v9NewsService.save(v9News);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("news:v9news:update")
    public R update(@RequestBody V9NewsEntity v9News){
		v9NewsService.updateById(v9News);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("news:v9news:delete")
    public R delete(@RequestBody Integer[] ids){
		v9NewsService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}